<template>
  <div>
    <CityHeader></CityHeader>
    <CitySearch :cities = "cityList"></CitySearch>
    <CityList :cities = "cityList" :hotCities = "hotCityList" :letter = "letter"></CityList>
    <CityAlphabet :cities = "cityList" @letterChange="handleLetterChange"></CityAlphabet>
  </div>
</template>

<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      cityList: {},
      hotCityList: [],
      letter: ''
    }
  },
  mounted () {
    this.getCityInfo()
  },
  methods: {
    getCityInfo () {
      axios.get('static/mook/city.json')
        .then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res) {
      if (res.data.ret && res.data.data) {
        this.cityList = res.data.data.cities
        this.hotCityList = res.data.data.hotCities
      }
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  }
}
</script>

<style lang="stylus" scoped>

</style>
